package com.franklin.java.configuration.sql.completion;

import com.franklin.java.api.state.BaseProjectPersistentState;
import com.franklin.java.api.state.converter.ColorConverter;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.project.Project;
import com.intellij.ui.JBColor;
import com.intellij.util.xmlb.annotations.OptionTag;

import java.awt.*;

/**
 * 颜色持久化
 * @author Franklin
 * @since 2021/9/2 18:38
 */
@State(name = "com.franklin.java.configuration.sql.completion.ColorState",
    storages = {@Storage(StoragePathMacros.WORKSPACE_FILE)})
public class ColorState extends BaseProjectPersistentState<ColorState> {

    @OptionTag(converter = ColorConverter.class)
    public Color color = JBColor.PINK;

    public ColorState(Project myProject) {
        super(myProject);
    }

    public ColorState() {
    }

    public static ColorState getInstance(Project project) {
        return project.getService(ColorState.class);
    }

    public static Color getColor(Project project) {
        return getInstance(project).color;
    }
}
